/**
 * Description:工厂相关信息
 * Created by qgn on 2018/8/3
 */
import { getSingleFactory } from '@/api/projectApi.js'

const factory = {
  state: {
    factoryInfo: [] // 工厂信息
  },
  mutations: {
    setFactory: (state, data) => {
      state.factoryInfo = data
    }
  },
  actions: {
    getFactory({ commit }) {
      return new Promise((resolve, reject) => {
        getSingleFactory({ factoryId: window.localStorage.factoryId }).then(response => {
          commit('setFactory', response.data)
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    }
  }
}

export default factory